package com.ymatou.iapi.im.testcase;

import com.ymatou.iapi.im.parameter.SendMessageToBuyerBean;
import com.ymatou.iapi.im.parameter.SetMessageSessionImportantBean;
import com.ymatou.iapi.im.service.SetMessageSessionImportantCall;
import com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean;
import com.ymatou.iapi.userregister.service.UserRegisterInfoRequestDtoCall;
import com.ymttest.business.service.ImCallService;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.database.sqlwapper.ImDefaultWapper;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;

import java.util.Map;

/**
*客服标记重要会话
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SetMessageSessionImportant{
	private static SetMessageSessionImportantBean setmessagesessionimportantBean;
	private static SetMessageSessionImportantCall setmessagesessionimportantCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("客服标记重要会话");
	}

	@Before
	public void caseUp() {
		setmessagesessionimportantBean=new SetMessageSessionImportantBean();
		setmessagesessionimportantCall=new SetMessageSessionImportantCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(setmessagesessionimportantCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SetMessageSessionImportant_01() {
		Logger.start(true,"客服标记重要会话");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer userId = urrc.getUserid();
			int fromUserId = 24635724;
			SendMessageToBuyerBean sendMessageToBuyerBean = ImCallService.initSendMessageToBuyerBean(fromUserId,userId,"nihao");
			ImCallService.SendMessageToBuyer(sendMessageToBuyerBean);

			setmessagesessionimportantBean.setUserId(fromUserId);
			setmessagesessionimportantBean.setToUserId(userId);
			setmessagesessionimportantCall.setData(setmessagesessionimportantBean);
			setmessagesessionimportantCall.callService();
			ImDefaultWapper im = new ImDefaultWapper();
			Map map = im.selectTotalCount(userId,fromUserId).get(0);
			Logger.verifyEquals("Success",setmessagesessionimportantCall.getString("Status"),"验证Staus");
			Logger.verifyEquals(1,map.get("IsImportant"),"验证是否标记为重要会话");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}